import React, { Component } from "react";
<<<<<<< HEAD
import {
  View,
  Text,
  ActivityIndicator,
  StyleSheet,
  ScrollView,
  RefreshControl
} from "react-native";
import { getPatientVital } from "../../api/config";
import { colors } from "../../Style/Colors";
import NoDataFound from "../../Components/NoDataFound";
import { setDate } from "../../Components/SetDate";
import Toast from "react-native-simple-toast";

class ViewVitals extends Component {
  state = {
    isLoading: true,
    param: "",
    resultText: "",
    data: [],
    refreshing: false
  };
  componentDidMount = async () => {
    try {
      const { type, refNo } = this.props.screenProps;
      getPatientVital(type, refNo)
        .then(data => {
          this.setState({ data, isLoading: false });
        })
        .catch(e => Toast.show(e.message));
    } catch (e) {
      Toast.show(e.message);
    }
  };

  onRefresh = () => {
    this.setState({ refreshing: true, isLoading: true });
    const { type, refNo } = this.props.screenProps;

    getPatientVital(type, refNo)
      .then(data => {
        this.setState({ data, isLoading: false, refreshing: false });
      })
      .catch(e => Toast.show(e.message));
  };

  render() {
    const { data, isLoading, refreshing } = this.state;
    return (
      <View style={styles.container}>
        {isLoading ? (
          <ActivityIndicator size="large" color={colors.primaryColor} />
        ) : this.state.data.length === 0 ? (
          <NoDataFound />
        ) : (
          <ScrollView
            showsVerticalScrollIndicator={false}
            refreshControl={
              <RefreshControl
                colors={[colors.primaryColor]}
                refreshing={refreshing}
                onRefresh={this.onRefresh}
              />
            }
          >
            {data.map((data, i) => (
              <View key={i} style={styles.wrapper}>
                <View
                  style={{
                    flexDirection: "row",
                    justifyContent: "space-between"
                  }}
                >
                  <Text style={styles.title}>{data.DISCRIPTION}</Text>
                  <Text>{data.V_VALUE}</Text>
                </View>
                <Text style={styles.data}>{setDate(data.ADD_DATETIME)}</Text>
              </View>
            ))}
          </ScrollView>
        )}
=======
import { View, Text } from "react-native";

class ViewVitals extends Component {
  render() {
    return (
      <View>
        <Text> Hello </Text>
>>>>>>> 503b0544130247b48d86f53bc47ed722f01e5c05
      </View>
    );
  }
}

<<<<<<< HEAD
const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginBottom: 4,
    backgroundColor: colors.offWhite
  },
  wrapper: {
    backgroundColor: colors.whiteColor,
    padding: 8,
    marginVertical: 2,
    marginHorizontal: 6,
    borderWidth: 0.3,
    borderColor: colors.lightGrey
  },
  title: {
    fontSize: 16,
    color: "#333",
    marginVertical: 4
  },
  date: {
    fontSize: 14,
    color: colors.lightGrey
  }
});

=======
>>>>>>> 503b0544130247b48d86f53bc47ed722f01e5c05
export default ViewVitals;
